﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="format-detection" content="telephone=no" />
    <title>智慧团建系统-通知公告</title>
    <link rel="icon" href="favicon.ico" mce_href="favicon.ico" type="image/x-icon">
	<link rel="shortcut icon" href="favicon.ico" mce_href="favicon.ico" type="image/x-icon">
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=IE8" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<meta http-equiv="Expires" content="0">
	<meta http-equiv="Pragma" content="no-cache">
	<meta http-equiv="Cache" content="no-cache">
	<meta http-equiv="kiben" content="no-cache">
	<meta http-equiv="Cache-Control" content="no-cache, must-revalidate">
	<!-- css -->
	<link type="text/css" rel="stylesheet" charset="utf-8" href="asset/bootstrap/css/bootstrap.css">
	<link rel="stylesheet" type="text/css" href="asset/fontawesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="asset/css/wangEditor-1.1.0.css">
    <link rel="stylesheet" type="text/css"  href="asset/css/comm.css" />
    <link type="text/css" rel="stylesheet" charset="utf-8" href="asset/css/cys.css">
    <script type="text/javascript" src="asset/jquery/jquery.js"></script>
    <script type="text/javascript" src="asset/js/wangEditor-1.1.0.js"></script>
	<style type="text/css">
		@charset "UTF-8";

		.ng-cloak,
		.x-ng-cloak,
		.ng-hide {
			display: none !important;
		}

		ng:form {
			display: block;
		}

		.ng-animate-block-transitions {
			transition: 0s all !important;
			-webkit-transition: 0s all !important;
		}

		.ng-hide-add-active,
		.ng-hide-remove {
			display: block !important;
		}
		
		.pull-right {
		    float: right !important;
		    display: inline-flex;
		}
		
    	.btn{padding: 0px 12px;}
		.searBOX {
		    background: #FFFFFF;
		    border: 0px solid #dfdfdf;
		    margin-left: 0px;
		    height: 550px;
	    }
	    
	    .searBOX .inpBox {
    		width: 100%;
    	}
    	.searBOX .inpBox .left {
    		width: 10%;
    	}
    	.searBOX .inpBox input.inptext, .searBOX .inpBox .selsty {
    		width: 89%;
    	}
    	.ecooBox {
    		height: 40px;
    		padding-left: 35%;
    	}
    	.wangEditor {
		    float: left;
		    width: 89%;
		}
		.wangEditor .textarea p {
		    color: #A5A3A3;
		}
		.wangEditor .textarea {
		    height: 405px !important;
		}
		.form-horizontal .form-group {
    		margin-left: 0px;
    		width: 89%;
    	}
    	#content {
    		min-height: 750px;
    		height: auto;
    	}
	</style>
	<script>
		$(function(){
			var $editor = $('#txtDiv').wangEditor();
			//显示 html / text
            var $textarea = $('#textarea'),
                $btnHtml = $('#btnHtml'),
                $btnText = $('#btnText'),
                $btnHide = $('#btnHide');
            $textarea.hide();
            $btnHtml.click(function(){
                $textarea.show();
                $textarea.val( $editor.html() );
            });
            $btnText.click(function(){
                $textarea.show();
                $textarea.val( $editor.text() );
            });
            $btnHide.click(function(){
                $textarea.hide();
            });
		});
		
		function TzggCtrl($injector,$scope, CtrlUtil, $element, $http, $sce) {
			var ctrl = this
			var isEdit = getParam('isEdit');
			//CtrlUtil.build(this, listUrl)
			var entity = null;
			$http.post(':root/tzgggl/queryTzgg',{
				id : getParam('id')
			}).success(function (r) {
				if(r){
					$scope.entity = r;
					$scope.modalBody=$sce.trustAsHtml(r.nr);
				}
			})
			this.cancel = function() {
				location.href = 'organization.html?isBack=4';
			};
			this.save = function (type) {
				var modalService = $injector.get('modalService');
				var bt = $.trim($('#bt').val());
				var nr = '';
				if(isEdit=='true'){
					nr = $.trim($('#txtDiv .textarea').html());
					nr = nr.substring(54,nr.length-6);
				}else{
					$('#txtDiv .textarea div').remove('.ng-binding');
					nr = $.trim($('#txtDiv .textarea').html());
				}
				var nr = encodeURIComponent(nr);
				if(bt == ''){
					modalService.error('标题不能为空', 1500);
					return;
				}
				if(nr == ''){
					modalService.error('内容不能为空', 1500);
					return;
				}			
				
				var fbzt = $scope.entity.fbzt== undefined ?0:$scope.entity.fbzt;
				if(type==1){
					fbzt = 1;
				}
				
				var id = isEdit=='true'?$scope.entity.id:getParam('id');
				
				var btn = $element.find('[file]')
				var config = {
					multipleFiles: false,
					autoUploading: true,
					browser: btn[0],
					maxSize: 1024 * 1024 * 100,
					//extFilters: [".jpg", ".jpeg", ".png", ".gif", ".bmp"],
					onComplete: function (file) {
						var attach = {}
						attach.fileName = file.name;
						attach.hash = eval('(' + file.msg + ')').message;
						attach.size = file.size;
						attach.uploading = false
						result.tpId = (attach.hash + '/' + attach.size)
						result.imageUrl = CtrlUtil.toImageUrl(result.tpId, 1)
						$scope.$$phase || $scope.$apply()
					},
					onSelect: function (list) {
						var notImage = false, overSize = false
						angular.forEach(list, function (v) {
							if (v.size > (1024 * 1024 * 20)) {
								overSize = true
							}
						})
						if (overSize) {
							toaster.pop({
								type: 'error',
								body: '文件大小不能超过100M',
								timeout: 800
							});
							$scope.$$phase || $scope.$apply()
						}
					}
				}
				var stream = $injector.get('UploadService').create(config)
			
				$http.post(':root/tzgggl/addTzgg', {
					id : id,
					fbzt : fbzt,
					cjr : $scope.entity.cjr,
					cjsj : $scope.entity.cjsj,
					bt : bt,
					nr : nr
				}).success(function(r) {
					if (r) {
						$injector.get('modalService').succ('添加成功。', 1500);
						setTimeout(function () {
							ctrl.cancel();
						}, 1000)
					}
				});
			}
			
		}
	</script>
</head>	
<body class="qm_bgcolor">
	<div id="header_wrap"></div>
    	
    <div class="inner_line index-main">
	    <div class="mainBOX ">
			<ul id="tab">
	    		<li>组织建设</li>
	    		<li>团情统计</li>
	    		<li>打卡管理</li>
	    		<li class="current">通知公告</li>
	    	</ul>
	        <div id="content">
				<div class="tabUI" style="display:none;">
	            	<div class="chartU">组织建设中</div>
	            </div>
	            <div class="tabUI" style="display:none;">
	            	<div class="chartU" style="display:none;"></div>
				</div>
				<div class="tabUI" style="display:none;">
	            	<div class="chartU"></div>
	            </div>
				<div class="tabUI" style="display:block;">
					<form class="form-horizontal">
		     			<div class="chartU" ng-controller="TzggCtrl as ctrl" ng-init="entity">
		            		<div class="searBOX">    
			            		<div class="inpBox">
			            			<span class="left">标题：</span>
			            			<input type="text" class="inptext" placeholder="标题" ng-model="entity.bt" name="entity.bt" id="bt" required="required">
			            		</div>
			            		<div class="inpBox">
			            			<span class="left">内容：</span>
				            		<div id='txtDiv' placeholder="请输入内容..." style='border:1px solid #cccccc; height:450px;padding-bottom: 32px;'>
						               <div data-ng-bind-html="modalBody"></div>
						            </div>
						        </div>
						        <div class="inpBox" style="display:none">
						        	<span class="left">上传文件：</span>
						        	<!-- <div class="thumbnail form-group col-md-12">
										<p>【提醒】： 上传格式不限，且大小不要超过10M。</p>
										<p>{{result.fileName}}</p>
										<div ng-show="result.filePercent" class="progress">
											<div class="progress-bar progress-bar-success" role="progressbar" aria-valuemin="0" aria-valuemax="100" ng-style="{width: result.filePercent}">
												<span ng-show="result.filePercent=='100%'" class="pull-right glyphicon glyphicon-ok"></span>
											</div>
										</div>
										<div file id="continue-file" class="btn btn-cys col-md-6">上传文件</div>
									 -->
									<div class="btn thumbnail btn btn-cys col-md-6" file title="" >
										<img class="img-responsive" style="max-height: 160px;" ng-src="{{result.imageUrl}}" alt="选择文件">
										<div class="text-muted" style="position: absolute; width: 100%; text-align: center; bottom: 2px;margin: 0px 0 -5px 80px;">【提醒】： 必须要上传哦，上传格式不限，且大小不要超过10M。</div>
									</div>
									<!-- <div class="thumbnail form-group col-md-12" style="margin-left: 10%;">
										<p>
											<a ng-href="{{ctrl.toImageUrl(result.fjId)}}" target="_blank">
												<img class="img-responsive" ng-src="{{ctrl.toImageUrl(result.fjId)}}">
											</a>
										</p>
									</div> -->
						        	<!-- <span class="left">上传文件：</span>
							        <label for="exampleInputFile">上传文件</label>
									<p class="bg-info help-block">【提醒】： 必须要上传哦，上传格式不限，且大小不要超过10M。</p>
									<p class="bg-success">{{file.originName}}</p>
									<div class="btn btn-cys" file title="点击上传文件">{{file.originName==''?'':'重新'}}上传</div> -->
								</div>
								
								<div class="inpBox">
									<span class="left">发布人：</span>
									<input type="text" class="inptext" class="inptext" placeholder="发布人" ng-model="entity.fbr" name="entity.fbr" disabled="disabled">
			            		</div>
							</div>
							<div class="ecooBox">
	             				<a href="javascript:;" ng-click="ctrl.cancel()" class="btn clearBtn">取消 </a> 
	             				<a href="javascript:;" ng-click="ctrl.save(1)" class="btn addBtn">发布</a>
	             				<a href="javascript:;" ng-click="ctrl.save(0)" ng-if="entity.fbzt != '1'" class="btn addBtn">保存</a>
	            			</div>
		          		</div>
	          		</form>
				</div>
			</div>
	   	</div>
	</div>
	<div id="footer_wrap"></div>
   
	<!-- js -->
	<script src="asset/outdatedbrowser/outdatedbrowser.js"></script>
    <script type="text/javascript" data-main="asset/main.js" src="asset/js/require.min.js"></script>
    <script type="text/javascript" src="asset/js/comm.js"></script>
    <script type="text/javascript" src="asset/js/banner.js"></script>
    <script type="text/javascript" src="asset/js/include.js"></script>
</body>
</html>